<jsp:include page="logincheck.jsp" />
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ page import="java.util.*" %>

<jsp:useBean id="bill" class="se2.Bill" scope="request"/>
<jsp:setProperty name="bill" property="*"/>

<html>

	<head>
		<title>Administration Console</title>
		<link rel="stylesheet" href="default.css" type="text/css" media="screen"></link>
	</head>

	<body>
		<div id="container">
			<div id="navigation">
<p>&nbsp;</p>
<jsp:include page="navigation.jsp" />
			</div>
			
			<div id="header">				
				<img src="images/header.png" />
			</div>

			<div id="content">
<!-- Main code -->
				
				<!-- Initialize the Bill Object -->
				<% 
					boolean odd = false;
					GregorianCalendar gc = new GregorianCalendar();
					GregorianCalendar gc2 = new GregorianCalendar();
					
					String start = request.getParameter("starttime");
					String end = request.getParameter("endtime");
					
					int syear = Integer.parseInt(start.substring(0,4));
					int sday = Integer.parseInt(start.substring(5,7));
					int smonth = Integer.parseInt(start.substring(8,10));
					int shour = Integer.parseInt(start.substring(11,13));
					int smin = Integer.parseInt(start.substring(14,16));
					int ssec = Integer.parseInt(start.substring(17,19));
					
					int eyear = Integer.parseInt(end.substring(0,4));
					int eday = Integer.parseInt(end.substring(5,7));
					int emonth = Integer.parseInt(end.substring(8,10));
					int ehour = Integer.parseInt(end.substring(11,13));
					int emin = Integer.parseInt(end.substring(14,16));
					int esec = Integer.parseInt(end.substring(17,19));
					
					gc.set(syear, smonth, sday, shour, smin, ssec);
					gc2.set(eyear, emonth, eday, ehour, emin, esec);
					bill.setStartDate(gc);
					bill.setEndDate(gc2);
					bill.setPhoneAccount(Integer.parseInt(request.getParameter("id")));
					bill.getBill();
				%>
				
				<h1>Phone Bill :: View</h1>
	
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
								
					<tr style="background-image: url('images/tableBackground.png');">
						<td style="background-image: url('images/tableBackground.png');" width="100">&nbsp;</td>
						<td style="background-image: url('images/tableBackground.png');" class="tableHeader">Time</td>
						<td style="background-image: url('images/tableBackground.png');" width="*"   class="tableHeader">Extension Dialed</td>
						<td style="background-image: url('images/tableBackground.png');" width="*"   class="tableHeader">Amount</td>
						<td style="background-image: url('images/tableBackground.png');" width="*"   class="tableHeader">Duration</td>
						<td style="background-image: url('images/tableBackground.png');" width="100" class="tableHeader">&nbsp;</td>
					</tr>

					<c:forEach var="callRecord" items="${bill.callRecords}">
						<% if (odd) { %>
							<tr style="background-image: url('images/tableBackground.png');">
						<% } else { %>
							<tr>
						<% } odd = !odd; %>
							<td></td>
							<td>${callRecord.formattedStartTime}</td>
							<td>${callRecord.toExtension}</td>
							<td>${callRecord.amount}</td>
							<td>${callRecord.duration}</td>
							<td></td>
						</tr>
					</c:forEach>
				</table>


<!-- Main Code -->
			</div>

			<div id="footer">
<jsp:include page="footer.jsp" />
			</div>
		</div>
	</body>

</html>